x86/vpmu: add cpu hot unplug notifier for vpmu
authorLuwei Kang <luwei.kang@intel.com>
Wed, 31 May 2017 06:41:43 +0000 (08:41 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 31 May 2017 06:41:43 +0000 (08:41 +0200)
commit2d08fb32bc3d252046748e908bafc1bf6376313e
tree88c431a3f00d96fe1396a923f3f01065ee4b5e30
parent02dc2aa7bf54602cf2d752a2af9fa38cee870fc8
x86/vpmu: add cpu hot unplug notifier for vpmu

Currently, Hot unplug a physical CPU with vpmu enabled may cause
system hang due to send a remote call to an offlined pCPU. This
patch add a cpu hot unplug notifer to save vpmu context before
cpu offline.

Consider one scenario, hot unplug pCPU N with vpmu enabled.
The vcpu which running on this pCPU will be switch to other
online cpu. A remote call will be send to pCPU N to save the
vpmu context before loading the vpmu context on this pCPU.
System will hang in function on_select_cpus() because of that
pCPU is offlined and can not do any respond.

The purpose of add a VPMU_CONTEXT_LOADED check in vpmu_arch_destroy()
before send a remote call to save vpmu contex is:
a. when a vpmu context has been loaded in a remote pCPU, make a
   remote call to save the vpmu contex and stop counters is necessary.
b. VPMU_CONTEXT_LOADED flag will be reset if a pCPU is offlined.
   this check will prevent send a remote call to an offlined pCPU.

Signed-off-by: Luwei Kang <luwei.kang@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
xen/arch/x86/cpu/vpmu.c